{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "31b4d270-6374-4417-ae90-783203820160",
   "metadata": {},
   "source": [
    "# 封装"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5bcdcf2e-f0e9-4221-bf05-c55c41fdd11e",
   "metadata": {},
   "outputs": [],
   "source": [
    "- 【属性前面加两个 __ 表示封装】\n",
    "- 面向对象之中类与对象的核心内容，也是最为重要的内容，但是除了基本的与对象是关系和引用传递关系，就是封装占据了一定的地位\n",
    "现在某些遍历或函数不希望外部调用，那么就可以进行封装。\n",
    "- 每一个被封装的属性，都有setter方法和getter方法。访问封装属性的唯一方法\n",
    "- setter方法公式：\n",
    "  def set_属性名(self, 属性名):\n",
    "      self.__属性名 = 属性名\n",
    "- getter方法公式：\n",
    "  def get_属性名(self):\n",
    "      return self.__属性名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38a8e4ae-6a1a-4f76-b5ec-170e0d465c58",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 获取和修改私有属性值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1c05ac8-b4c5-4fe3-8a89-b4727ccf4722",
   "metadata": {},
   "source": [
    "# 多态"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "336cc615-4536-46dd-b240-42822976d405",
   "metadata": {},
   "source": [
    "- 定义：多态是一种使用对象的方式（一个抽象类有多个子类），子类重写父类方法，调用不同子类对象，可以产生不同的执行结果\n",
    "- 好处：调用灵活，有了多态，更容易编写出通用的代码，"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
